<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="newAjax3.js"></script>
    <script>
        window.onload=function(){
            var oBtn=document.getElementById('btn');
            var url='post.php';
//            url='login.php';
//            login.php?act=xxx&user=xxx&pass=xxx&phone=xxx&num=xxx;

            oBtn.onclick=function(){
                var data=ajax(
                    url,
                    'post',
                    {
                        a:12,       //a=12&b=5;
                        b:5
                    },function(str){
                        console.log(str);
                    });
            };

            var json={
                a:12,       //a=12&b=5;
                b:5
            };

            function toStr(data){
                data.t=Math.random();
                var arr=[];
                for(var name in data){
                    arr.push(name+'='+data[name]);
                }
                return arr.join('&');
            }
            console.log(str);

        }
    </script>
</head>
<body>
    <input type="button" value="按钮" id="btn">
</body>
</html>